package jobs;

// 抽象策略接口
interface PromotionStrategy {
    void promote();
}

// 满减策略
class FullReduction implements PromotionStrategy {
    @Override
    public void promote() {
        System.out.println("国庆节促销：满200减50");
    }
}

// 打折策略
class Discount implements PromotionStrategy {
    @Override
    public void promote() {
        System.out.println("圣诞节促销：全场8折");
    }
}

// 上下文类
class PromotionContext {
    private PromotionStrategy strategy;
    public PromotionContext(PromotionStrategy strategy) {
        this.strategy = strategy;
    }
    public void executePromotion() {
        strategy.promote();
    }
}

// 测试类
public class PromotionStrategyTest {
    public static void main(String[] args) {
        PromotionContext context;
        // 国庆节促销
        context = new PromotionContext(new FullReduction());
        System.out.print("国庆节: ");
        context.executePromotion();
        // 圣诞节促销
        context = new PromotionContext(new Discount());
        System.out.print("圣诞节: ");
        context.executePromotion();
    }
}
